package com.lyw.GeoLocationClient.ui;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import com.lyw.GeoLocationClient.R;
import com.lyw.GeoLocationClient.ui.adapter.LauncherGridAdapter;
import com.lyw.GeoLocationClient.ui.model.LauncherItem;

import java.util.ArrayList;

public class TrafficLauncherActivity extends Activity{
    private GridView mGridView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_launcher);

        mGridView = (GridView) findViewById(R.id.launcher_grid);

        final ArrayList<LauncherItem> list = new ArrayList<>();

        LauncherItem attendance = new LauncherItem(R.drawable.logo_uidemo, getString(R.string.attendance));
        attendance.setOnclickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                navToAttendance();
            }
        });
        LauncherItem travel = new LauncherItem(R.drawable.logo_uidemo, getString(R.string.travel));
        travel.setOnclickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                navToTravel();
            }
        });

        list.add(attendance);
        list.add(travel);

        LauncherGridAdapter adapter =
                new LauncherGridAdapter(this, R.layout.launcher_item, list);
        mGridView.setAdapter(adapter);
        mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                list.get(position).getListener().onItemClick(parent,view,position,id);
            }
        });
    }

    private void navToTravel() {
    }

    private void navToAttendance() {
    }
}
